local priority =6
 
EntitySystem.updatesystem("fireLaser", priority, function(dt)
  for e in pairs(EntitySystem.query("weaponized")) do

    if e.reload.isFiring then
      if e.reload.canFire then        
        if e.trackPlayer then
          --Multiple Weapons?
          if e.weapons then
            if e.weapons.selection == 2 then
            else
              FireLaser_TrackPlayer(e)
            end
          else
            --Only fires lasers
            FireLaser_TrackPlayer(e)
          end
        else
          --Multiple weapons?
          if e.weapons then
            if e.weapons.selection == 2 then
            else
              FireLaser_NoTrackPlayer(e)
            end
          else
            --Only fires lasers
            FireLaser_NoTrackPlayer(e)
          end
        end
        
        e.reload.canFire = false
        e.reload.timer = 0
      elseif e.reload.timer >= e.reload.speed then
        e.reload.canFire = true
        e.reload.timer = 0
      end
    
    end
  
    if e.reload.timer < e.reload.speed then
      e.reload.timer = e.reload.timer + dt
    end
  
  end
end)
--
--
--
--
function FireLaser_TrackPlayer(e)
  local fireXSpeed = math.cos(e.physics.body:getAngle())*15
  local fireYSpeed = math.sin(e.physics.body:getAngle())*15
  
  local laser = EntitySystem.entity.laser(e.position.x, e.position.y, fireXSpeed, fireYSpeed, e.physics.body:getAngle(), e.reload.typ, e.reload.cat, player.position.x, player.position.y)
end
--
function FireLaser_NoTrackPlayer(e)
  local fireXSpeed = math.cos(e.physics.body:getAngle())*15
  local fireYSpeed = math.sin(e.physics.body:getAngle())*15
  
  local laser = EntitySystem.entity.laser(e.position.x, e.position.y, fireXSpeed, fireYSpeed, e.physics.body:getAngle(), e.reload.typ, e.reload.cat,e.position.x,e.position.y)
end